package com.bss.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.andy.basics.Dao;
import com.andy.basics.GenericDao;
import com.bss.dao.ReceiptDao;
import com.bss.model.Receipt;

@Service
@Scope("session")
public class ReceiptService extends com.andy.basics.Service<Receipt> {

	@Autowired
	private ReceiptDao receiptDao;

	@Autowired
	private GenericDao genericDao;

	@Override
	public Dao<Receipt> getDao() {
		throw new UnsupportedOperationException();
	}

	@Transactional
	public Receipt findReceipt(final int receiptId) {
		Receipt receipt = this.receiptDao.findById(receiptId);
		this.genericDao.initialize(receipt.getPayments());
		return receipt;
	}

}
